package com.huarui.user.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.ewaf.framework.model.ListModel;
import org.ewaf.framework.service.BaseService;

import com.huarui.user.dao.ILoginHistoryDao;
import com.huarui.user.model.LoginHistory;

public class LoginHistoryService extends BaseService {

	private ILoginHistoryDao getDao() {
		return (ILoginHistoryDao) dao;
	}

	public List<LoginHistory> getbyuserId(Integer userId) {

		return getDao().getbyUserId(userId);

	}

	@SuppressWarnings("unchecked")
	public ListModel<LoginHistory> getLoginHistoryByCondition(ListModel lm, Integer userId) {
		lm.setTotal(this.getDao().countByConditions(userId));
		Map map = new HashMap<String, String>();
		map.put("userId", userId);
		map.put("orderBy", lm.getOrderBy());
		map.put("start", lm.getStart());
		map.put("pageSize", lm.getPageSize());
		map.put("desc", lm.isDesc());
		List<LoginHistory> loginHistoryList = this.getDao()
				.getLoginhistoryByCondition(map);

		lm.setResult(loginHistoryList);
		return lm;
	}
}
